Store the pre-signed Bitcoin claim or refund — body: { kind: "claim" | "refund", toAddress, levels: [{ feeSats, psbtBase64, signaturesHex }] }
curl --request POST \
--url https://api.hashlock.markets/v1/swaps/{id}/legs/{leg}/presign \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"toAddress": "<string>",
"levels": [
{
"feeSats": 123,
"psbtBase64": "<string>",
"signaturesHex": [
"<string>"
]
}
]
}
'import requests
url = "https://api.hashlock.markets/v1/swaps/{id}/legs/{leg}/presign"
payload = {
"toAddress": "<string>",
"levels": [
{
"feeSats": 123,
"psbtBase64": "<string>",
"signaturesHex": ["<string>"]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
toAddress: '<string>',
levels: [{feeSats: 123, psbtBase64: '<string>', signaturesHex: ['<string>']}]
})
};
fetch('https://api.hashlock.markets/v1/swaps/{id}/legs/{leg}/presign', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.hashlock.markets/v1/swaps/{id}/legs/{leg}/presign",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'toAddress' => '<string>',
'levels' => [
[
'feeSats' => 123,
'psbtBase64' => '<string>',
'signaturesHex' => [
'<string>'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.hashlock.markets/v1/swaps/{id}/legs/{leg}/presign"
payload := strings.NewReader("{\n \"toAddress\": \"<string>\",\n \"levels\": [\n {\n \"feeSats\": 123,\n \"psbtBase64\": \"<string>\",\n \"signaturesHex\": [\n \"<string>\"\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.hashlock.markets/v1/swaps/{id}/legs/{leg}/presign")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"toAddress\": \"<string>\",\n \"levels\": [\n {\n \"feeSats\": 123,\n \"psbtBase64\": \"<string>\",\n \"signaturesHex\": [\n \"<string>\"\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hashlock.markets/v1/swaps/{id}/legs/{leg}/presign")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"toAddress\": \"<string>\",\n \"levels\": [\n {\n \"feeSats\": 123,\n \"psbtBase64\": \"<string>\",\n \"signaturesHex\": [\n \"<string>\"\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"swap": {
"id": "<string>",
"threadId": "<string>",
"status": "<string>",
"makerId": "<string>",
"takerId": "<string>",
"initiatorUserId": "<string>",
"hashlock": "<string>",
"aAssetId": "<string>",
"aChain": "<string>",
"aAmount": "<string>",
"aTimelock": "2023-11-07T05:31:56Z",
"bAssetId": "<string>",
"bChain": "<string>",
"bAmount": "<string>",
"bTimelock": "2023-11-07T05:31:56Z",
"rfqId": "<string>",
"secretCiphertext": "<string>",
"meta": {},
"feeBps": 123,
"feeAmount": "<string>",
"feeAssetId": "<string>",
"aPayoutAddress": "<string>",
"aClaimTo": "<string>",
"aRefundAddress": "<string>",
"aHtlcAddress": "<string>",
"aFundTx": "<string>",
"aFundOutpoints": [
{
"txid": "<string>",
"vout": 123,
"value": 123
}
],
"aClaimTx": "<string>",
"aRefundTx": "<string>",
"bPayoutAddress": "<string>",
"bClaimTo": "<string>",
"bRefundAddress": "<string>",
"bHtlcAddress": "<string>",
"bFundTx": "<string>",
"bFundOutpoints": [
{
"txid": "<string>",
"vout": 123,
"value": 123
}
],
"bClaimTx": "<string>",
"bRefundTx": "<string>",
"timeline": {
"fundA": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
},
"fundB": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
},
"reveal": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
},
"payoutA": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
},
"payoutB": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
}
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Swaps and settlement
Store the pre-signed Bitcoin claim or refund — body: { kind: "claim" | "refund", toAddress, levels: [{ feeSats, psbtBase64, signaturesHex }] }
Each level is verified against the escrow’s confirmed outputs and the script’s key for that branch: one output to toAddress, one signature per input; a claim by the receiver key with locktime 0, a refund by the sender key with locktime = the leg’s timelock and non-final inputs.
POST
/
v1
/
swaps
/
{id}
/
legs
/
{leg}
/
presign
Store the pre-signed Bitcoin claim or refund — body: { kind: "claim" | "refund", toAddress, levels: [{ feeSats, psbtBase64, signaturesHex }] }
curl --request POST \
--url https://api.hashlock.markets/v1/swaps/{id}/legs/{leg}/presign \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"toAddress": "<string>",
"levels": [
{
"feeSats": 123,
"psbtBase64": "<string>",
"signaturesHex": [
"<string>"
]
}
]
}
'import requests
url = "https://api.hashlock.markets/v1/swaps/{id}/legs/{leg}/presign"
payload = {
"toAddress": "<string>",
"levels": [
{
"feeSats": 123,
"psbtBase64": "<string>",
"signaturesHex": ["<string>"]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
toAddress: '<string>',
levels: [{feeSats: 123, psbtBase64: '<string>', signaturesHex: ['<string>']}]
})
};
fetch('https://api.hashlock.markets/v1/swaps/{id}/legs/{leg}/presign', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.hashlock.markets/v1/swaps/{id}/legs/{leg}/presign",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'toAddress' => '<string>',
'levels' => [
[
'feeSats' => 123,
'psbtBase64' => '<string>',
'signaturesHex' => [
'<string>'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.hashlock.markets/v1/swaps/{id}/legs/{leg}/presign"
payload := strings.NewReader("{\n \"toAddress\": \"<string>\",\n \"levels\": [\n {\n \"feeSats\": 123,\n \"psbtBase64\": \"<string>\",\n \"signaturesHex\": [\n \"<string>\"\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.hashlock.markets/v1/swaps/{id}/legs/{leg}/presign")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"toAddress\": \"<string>\",\n \"levels\": [\n {\n \"feeSats\": 123,\n \"psbtBase64\": \"<string>\",\n \"signaturesHex\": [\n \"<string>\"\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hashlock.markets/v1/swaps/{id}/legs/{leg}/presign")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"toAddress\": \"<string>\",\n \"levels\": [\n {\n \"feeSats\": 123,\n \"psbtBase64\": \"<string>\",\n \"signaturesHex\": [\n \"<string>\"\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"swap": {
"id": "<string>",
"threadId": "<string>",
"status": "<string>",
"makerId": "<string>",
"takerId": "<string>",
"initiatorUserId": "<string>",
"hashlock": "<string>",
"aAssetId": "<string>",
"aChain": "<string>",
"aAmount": "<string>",
"aTimelock": "2023-11-07T05:31:56Z",
"bAssetId": "<string>",
"bChain": "<string>",
"bAmount": "<string>",
"bTimelock": "2023-11-07T05:31:56Z",
"rfqId": "<string>",
"secretCiphertext": "<string>",
"meta": {},
"feeBps": 123,
"feeAmount": "<string>",
"feeAssetId": "<string>",
"aPayoutAddress": "<string>",
"aClaimTo": "<string>",
"aRefundAddress": "<string>",
"aHtlcAddress": "<string>",
"aFundTx": "<string>",
"aFundOutpoints": [
{
"txid": "<string>",
"vout": 123,
"value": 123
}
],
"aClaimTx": "<string>",
"aRefundTx": "<string>",
"bPayoutAddress": "<string>",
"bClaimTo": "<string>",
"bRefundAddress": "<string>",
"bHtlcAddress": "<string>",
"bFundTx": "<string>",
"bFundOutpoints": [
{
"txid": "<string>",
"vout": 123,
"value": 123
}
],
"bClaimTx": "<string>",
"bRefundTx": "<string>",
"timeline": {
"fundA": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
},
"fundB": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
},
"reveal": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
},
"payoutA": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
},
"payoutB": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
}
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Authorizations
Body
application/json